-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: split cli methods to easy testing #3
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Felipe Zipitria <[email protected]>
Co-authored-by: Max Leske <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
8b1991a
to
4477d11
Compare
Signed-off-by: Felipe Zipitria <[email protected]>
4477d11
to
646208c
Compare
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
4db6a91
to
3b4b403
Compare
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Co-authored-by: Max Leske <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Co-authored-by: Max Leske <[email protected]>
Co-authored-by: Max Leske <[email protected]>
Ugh, the code review changes broke it. I'll try to fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a first review I found only one thing (see above), but I'd like to run few tests (after we cleared my review).
|
||
if "operator_argument" in d: | ||
oparg = re.findall(r"%\{(tx.[^%]*)\}", d['operator_argument'], re.I) | ||
oparg = re.findall(r"%\{(tx.[^%]*)}", d["operator_argument"], re.I) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you removed the \
from the front of the close bracket. Is that accidentally or on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless, the expression are equivalent. In python even the opening brace does not need to be escaped, unless it's umbiguous (e.g., looks like a range expression).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Python regular expressions, special characters that need to be escaped outside of character classes include: *, +, ?, {, (, ), ^, $, |, and \
. Inside character classes, you need to escape ], -, ^, and \
if they are used in a way that could confuse the regex parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, formatting should be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, formatting should be consistent.
Yeah, this is what I noticed.
2a8ba08
to
0500fea
Compare
0500fea
to
025f053
Compare
Signed-off-by: Felipe Zipitria <[email protected]>
025f053
to
3f10697
Compare
"endLine": line1 + line2, | ||
"message": "an indentation error has found", | ||
} | ||
errmsgf(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function errmsgf()
is undefined.
print("::debug::%s" % (msg)) | ||
else: | ||
print(msg) | ||
from crs_linter.logger import Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a minimal modification we could make this tool more flexible, I mean if someone wants to avoid to use uv
, then they can use native was.
diff --git a/src/crs_linter/cli.py b/src/crs_linter/cli.py
index 5469cf7..5580c21 100755
--- a/src/crs_linter/cli.py
+++ b/src/crs_linter/cli.py
@@ -10,8 +10,14 @@ import re
from dulwich.contrib.release_robot import get_current_version, get_recent_tags
from semver import Version
-from crs_linter.linter import Check
-from crs_linter.logger import Logger
+try:
+ from linter import Check
+except:
+ from crs_linter.linter import Check
+try:
+ from logger import Logger
+except:
+ from crs_linter.logger import Logger
def remove_comments(data):
And anyone can run from that directory with command ./cli.py ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you mean. People will still need to install prerequisites, right?
How is people going to install requirements (we will provide the option, of course)? If you want to use native, you probably also want to use virtualenv, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use native, you probably also want to use virtualenv, right?
Yes, of course.
choices=["native", "github"], | ||
required=False, | ||
) | ||
parser.add_argument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument isn't documented in README.md (even it's mandatory).
Edit: I meant the -d DIRECTORY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Now being a tool that lives outside the coreruleset directory, it needs it to properly catch the git labels.
It might not be needed if we are passing the proper version 🤔
Signed-off-by: Felipe Zipitria <[email protected]>
what
why